package com.candy.control;

import com.alibaba.fastjson2.JSON;
import com.candy.service.UserInfoSerivce;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.LinkedList;

@WebServlet("/getUserInfoes")
public class GetUserInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserInfoSerivce serivce=new UserInfoSerivce();
        LinkedList<LinkedHashMap<String,Object>> userinfoes= serivce.getUserInfores();
//        将数据进行转换成JSON字符串格式
        String userinfoStr=JSON.toJSONString(userinfoes);
//        将数据响应给前端
        resp.getWriter().println(userinfoStr);
    }
}
